﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;

namespace SAR
{
    public partial class HuiboMoniPageControl
	{
        public HuiboMoniPageControl()
		{
			this.InitializeComponent();


             //初始化
            pageCtrLists[0] = "HuiboMoni0.xaml";
            pageCtrLists[1] = "HuiboMoni1.xaml";
            pageCtrLists[2] = "HuiboMoni2.xaml"; 
            pageCtrLists[3] = "HuiboMoni3.xaml" ;
            pageCtrLists[4] = "HuiboMoni4.xaml";
            pageCtrLists[5] = "HuiboMoni5.xaml";
            pageCtrLists[6] = "HuiboMoni6.xaml";

            pageCtrLists[7] = "HuiboMoni7.xaml";
            pageCtrLists[8] = "HuiboMoni8.xaml";
            

           
			// 在此点之下插入创建对象所需的代码。
		}


         //属性，页面路径数组，必须初始化！
         public string[] pageCtrLists = new string[100];

         private int currentStp = 0;

         private bool isLoaded = false;

         //属性CurrentStep，代表当前步骤
         public int CurrentStep
         {
             get
             {
                 return currentStp;
             }
             set
             {
                 this.currentStp = value;

                 //设置进度条
                 this.stepBar.SARCurrentStep = currentStp;
             }
         }
         private int maxStepNum = 8;

         //属性MaxStepNum，代表流程最大步骤数

         public int MaxStepNum
         {
             get
             {
                 return maxStepNum;
             }

             set
             {
                 this.maxStepNum = value;
             }
         }

         private string currentPagePath;

         //属性，当前页面相对路径
         public string CurrentPagePath
         {
             get
             {
                 return currentPagePath;
             }
             set
             {
                 this.currentPagePath = value;
                 this.DoPage.Source = new System.Uri(currentPagePath, UriKind.Relative);

                 
             }
         }

         private void sARLoadButton1_SARClick(object sender, MouseButtonEventArgs e)
         {
             nextStepBtn_SARNextClick(this, e);
             this.loadButton1.Visibility = Visibility.Hidden;
             this.cancelBtn.Visibility = Visibility.Hidden;
             this.openFile.Visibility = Visibility.Hidden;

             this.stepBar.Visibility = Visibility.Visible;
             this.preStepBtn.Visibility = Visibility.Visible;
             this.nextStepBtn.Visibility = Visibility.Visible;

             this.grid1.Margin = new Thickness(20, 84, 20, 71);

             Page currentPage = this.DoPage.Content as Page;
             if (currentPage is HuiboMoni0)
             {
                 (currentPage as HuiboMoni0).LoadData();
             }
             currentStp = 6;
             this.stepBar.SARCurrentStep = currentStp - 1;
             this.DoPage.Source = new System.Uri(pageCtrLists[currentStp], UriKind.Relative);
         }


         //上一步点击事件
         private void preStepBtn_SARPreClick(object sender, MouseButtonEventArgs e)
         {
             BasePageClass currentPage = this.DoPage.Content as BasePageClass;
             currentPage.PreClick();


             this.nextStepBtn.SARIsEnabled = true;
             if (currentStp > 0)
             {
                 currentStp--;
                 if (currentStp == 0)
                 {
                     this.stepBar.Visibility = Visibility.Hidden;
                     this.preStepBtn.Visibility = Visibility.Hidden;
                     this.nextStepBtn.Visibility = Visibility.Hidden;
                     this.loadButton1.Visibility = System.Windows.Visibility.Visible;
                     this.openFile.Visibility = Visibility.Visible;
                     this.cancelBtn.Visibility = Visibility.Visible;
                     if (!isLoaded)
                     {
                         this.loadButton1.SARIsEnabled = false;
                     }

                     this.grid1.Margin = new Thickness(20, 4, 20, 71);
                 }               

             }
             else
             {
                 currentStp = 0;
                 this.stepBar.Visibility = Visibility.Hidden;
                 this.preStepBtn.Visibility = Visibility.Hidden;
                 this.nextStepBtn.Visibility = Visibility.Hidden;
                 this.loadButton1.Visibility = System.Windows.Visibility.Visible;
                 this.openFile.Visibility = Visibility.Visible;
                 this.cancelBtn.Visibility = Visibility.Visible;
                 if (!isLoaded)
                 {
                     this.loadButton1.SARIsEnabled = false;
                 }

                 this.grid1.Margin = new Thickness(20, 4, 20, 71);

             }
             this.stepBar.SARCurrentStep = currentStp - 1;
             this.DoPage.Source = new System.Uri(pageCtrLists[currentStp], UriKind.Relative);

             
         }

         //下一步点击事件
         private void nextStepBtn_SARNextClick(object sender, MouseButtonEventArgs e)
         {
             BasePageClass currentPage = this.DoPage.Content as BasePageClass;
             currentPage.NextClick();

             this.preStepBtn.SARIsEnabled = true;
             if (currentStp >= maxStepNum - 1)
             {
                 currentStp = maxStepNum;
                 this.nextStepBtn.SARIsEnabled = false;
             }
             else
             {
                 currentStp++;
             }
             this.stepBar.SARCurrentStep = currentStp - 1;
             this.DoPage.Source = new System.Uri(pageCtrLists[currentStp], UriKind.Relative);

             

         }

         private void openFile_SARClick(object sender, MouseButtonEventArgs e)
         {
             //打开参数文件

             this.loadButton1.SARIsEnabled = true;
             isLoaded = true;
         }

        //取消
        private void cancelBtn_SARClick(object sender, MouseButtonEventArgs e)
        {
            nextStepBtn_SARNextClick(this, e);

            this.loadButton1.Visibility = Visibility.Hidden;
            this.cancelBtn.Visibility = Visibility.Hidden;
            this.openFile.Visibility = Visibility.Hidden;
            this.stepBar.Visibility = Visibility.Visible;
            this.preStepBtn.Visibility = Visibility.Visible;
            this.nextStepBtn.Visibility = Visibility.Visible;

            this.grid1.Margin = new Thickness(20, 84, 20, 71);

        }       

    }
}